import java.io.FileInputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Properties;

public class Log {
    public final static int OK = 0;
    public final static int NOTICE = 1;
    public final static int WARNING = 2;
    public final static int ERROR = 3;
	public final static int DEBUG = 4;

    private static String logPath;

    static {
        Properties prop = new Properties();
        try {
            prop.load(new FileInputStream("config.properties"));
            logPath = prop.getProperty("logPath");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void log(String message) {
        log(message, WARNING);
    }
    public static void log(String message, int level) {
        log(null, message, level);
    }
    public static void log(Object src, String message, int level) {

        System.out.println("----------------------------------------");
        System.out.println(new Date());
        String logMessage = "";
        if (src == Main.class) {
            logMessage += "SERVER     ";
		}
		else {
			if (src == TestAttemptThread.class) {
				logMessage += "TEST THREAD";
			}
			else {
				logMessage += "UNDEFINED  ";
			}
		}
        switch (level) {
            case OK:
                logMessage += "[   OK  ]";
                break;
            case NOTICE:
                logMessage += "[ NOTICE]";
                break;
            case WARNING:
                logMessage += "[WARNING]";
                break;
            case ERROR:
                logMessage += "[ ERROR ]";
                break;
			case DEBUG:
				logMessage += "[ DEBUG ]";
                break;
        }
        System.out.println(logMessage + ": " + message);
    }
}
